improvement(api): consolidate public v2 route handling - #6370
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryMedium Risk Overview
Dozens of v2 route modules (audit logs, billing, credentials, custom tools, files, knowledge, logs, MCP servers, etc.) are refactored to register only their contract, rate-limit endpoint, optional Adds Reviewed by Cursor Bugbot for commit 79177e9. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThe PR consolidates standard public v2 route handling without leaving an eligible follow-up defect.
Confidence Score: 5/5The PR appears safe to merge because no blocking failure remains. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/app/api/public-api-route-handler.ts | Introduces the shared API-key route lifecycle while preserving canonical v2 validation and unhandled-error responses. |
| apps/sim/lib/core/utils/with-route-handler.ts | Extends shared route handling to consistently apply request context, response headers, logging, and configurable unhandled-error rendering. |
| apps/sim/app/api/v1/middleware.ts | Replaces the authenticated user-ID assertion with an explicit invariant check. |
| apps/sim/lib/api/server/validation.ts | Adds customizable oversized-payload handling used by migrated public v2 routes. |
| scripts/check-api-validation-contracts.ts | Recognizes shared-wrapper routes as contract-validated during strict API validation checks. |
Sequence Diagram
sequenceDiagram
participant Client
participant Wrapper as withPublicApiRouteHandler
participant RateLimit as API-key / rate limit
participant Gate as v2 rollout gate
participant Parser as Contract parser
participant Route as Endpoint handler
Client->>Wrapper: v2 request
Wrapper->>RateLimit: authenticate and check limit
RateLimit-->>Wrapper: user and rate-limit context
Wrapper->>Gate: verify v2 access
Gate-->>Wrapper: allowed
Wrapper->>Parser: parse params, query, headers, and body
Parser-->>Wrapper: typed input
Wrapper->>Route: input and auth context
Route-->>Wrapper: endpoint response
Wrapper-->>Client: response with request/rate-limit headers
Reviews (4): Last reviewed commit: "improvement(api): consolidate public v2 ..." | Re-trigger Greptile
ebdbeb0 to
6ba7fd8
Compare
|
@cursor review |
6ba7fd8 to
445ac76
Compare
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 6ba7fd8. Configure here.
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 445ac76. Configure here.
445ac76 to
79177e9
Compare
Summary
Type of Change
Testing
bun run lintbun run --cwd apps/sim type-checkbun run check:api-validation:strictbun run check:openapiChecklist